package util.jackson.serializer;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;

/**
 * @author Gregory Boissinot
 */
public class JacksonComparator {

    private JacksonComparator() {
    }

    public static boolean isSameJSONValues(String actualJSONValue, String expectedJSONValue) {
        ObjectMapper mapper = new ObjectMapper();
        try {
            JsonNode actualJsonNode = mapper.readTree(actualJSONValue);
            JsonNode expectedJsonNode = mapper.readTree(expectedJSONValue);
            return actualJsonNode.equals(expectedJsonNode);
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        }
    }
}
